package com.le.tester.book.effectivejava3rdchinese.articlefiftynine;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.TemporalAdjusters;
import java.util.Random;

/**
 * createTime：2022/9/3 13:42
 * description：方法测试
 */
public class Tester {

    //Random rnd = new Random();

    public static int f1(int n) {
        Random rnd = new Random();
        return Math.abs(rnd.nextInt()) % n;
    }

    public static void main(String[] args) {
//        int n = 2 * (Integer.MAX_VALUE / 3);
//        int low = 0;
//        for (int i = 0; i < 1000000; i++) if (f1(n) < n / 2) low++;
//        System.out.println(low);
        LocalDate today = LocalDate.now();
        LocalDate firstDay = today.with(TemporalAdjusters.firstDayOfMonth());
        LocalDate lastDay = today.with(TemporalAdjusters.lastDayOfMonth());

        LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
        LocalDateTime endTime = LocalDateTime.of(lastDay, LocalTime.MAX);

        Timestamp startTimestamp = Timestamp.valueOf(startTime);
        Timestamp endTimestamp = Timestamp.valueOf(endTime);
        System.out.println(startTimestamp);
        System.out.println(endTimestamp);

    }
}
